const pub = {
  publish() {
    dp.notify()
  }
}

const watcher1 = { update() { console.log(1) } }
const watcher2 = { update() { console.log(2) } }
const watcher3 = { update() { console.log(3) } }

class Dep {
  constructor() {
    this.subs = [watcher1, watcher2, watcher3]
  }

  notify() {
    this.subs.forEach(item => item.update())
  }
}

const dp = new Dep()

pub.publish()
